<?php
declare(strict_types=1);
namespace SixShop\Eav\Model;

use think\Model;
use think\model\concern\SoftDelete;
use think\model\relation\HasMany;

/**
 * Class SixShop\Eav\Model\EavAttributeModel
 *
 * @property bool $is_required 是否必填
 * @property int $entity_type_id 关联实体类型
 * @property int $id
 * @property string $attribute_code 属性编码
 * @property string $backend_type 存储类型(int/varchar/decimal/text), 需与frontend_input匹配
 * @property string $create_time
 * @property string $delete_time
 * @property string $frontend_input 表单控件类型
 * @property string $frontend_label 显示标签
 * @property string $update_time
 * @method static \think\db\Query onlyTrashed()
 * @method static \think\db\Query withTrashed()
 */
class EavAttributeModel extends Model
{
    use SoftDelete;
    protected function getOptions(): array
    {
        return [
            'name' => 'extension_eav_attribute'
        ];
    }

    public function optionList(): HasMany
    {
        return $this->hasMany(EavAttributeOptionModel::class, 'attribute_id', 'id');
    }
}
